﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<style type="text/css">
    .ui-jqgrid .table-bordered th {
        height: 52px !important;
    }
</style>
<script>
    var currRowId = 1;
    var currStatus = '0';
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        $('select').bindSelect();
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/BOM/Product/GetJqxlAllListJson",
            postData: { status: $("input[type='radio'].category:checked").val(), keyword: $("#txt_keyword").val() },
            height: $(window).height() - 142,
            colModel: [
                {
                    label: '下料卡号', name: 'MatNO', width: 110, align: 'center', sortable: false, frozen: true, formatter: function (cellvalue) {
                        return "<a href='javascript:;' onclick='showDetail(\"" + cellvalue + "\")'>" + cellvalue + "</a>";
                    }
                },
                {
                    label: '说明', name: 'MaintainStatus', width: 40, align: 'center', sortable: false, formatter: function (cellvalue) {
                        return cellvalue == "0" ? "编辑" : "发布";
                    }
                },
                { label: '毛坯<br />符号', name: 'Sign_MP', width: 35, align: 'center', sortable: false },
                { label: '材料牌号', name: 'MaterialCodeAll', width: 150, align: 'left', sortable: false },
                { label: '材料规格(mm)', name: 'MaterialSizesAll', width: 180, align: 'left', sortable: false },
                { label: '开卷尺寸(mm)', name: 'MaterialSizesLast', width: 100, align: 'left', sortable: false },
                { label: '剪切规格(mm)', name: 'MaterialSizes_J', width: 100, align: 'left', sortable: false },
                { label: '投料重量(Kg)', name: 'FQuantity_GBZL', width: 90, align: 'right', sortable: false },
                { label: '一张几块', name: 'FYZJK', width: 60, align: 'right', sortable: false },
                { label: '一块几件', name: 'FYKJJ', width: 60, align: 'right', sortable: false },
                { label: '一张几件', name: 'FYZJK_FYKJJ', width: 60, align: 'right', sortable: false },
                { label: '零件净重(Kg)', name: 'PartsNetWeight', width: 80, align: 'right', sortable: false },
                { label: '材料定额(Kg)', name: 'MaterialQuotaAll', width: 120, align: 'right', sortable: false },
                { label: '利用率(%)', name: 'LYL_All', width: 120, align: 'right', sortable: false },
                {
                    label: '方向', name: 'FiberDirection', width: 50, align: 'center', sortable: false, formatter: function (cellvalue) {
                        return cellvalue == "1" ? "是" : "";
                    }
                },
                {
                    label: '毛坯类别', name: 'RoughsType', width: 60, align: 'center', sortable: false, formatter: function (cellvalue) {
                        return cellvalue == "K" ? "块料" : cellvalue == "T" ? "条料" : cellvalue == "Y" ? "异形" : cellvalue == "L" ? "落料" : "";
                    }
                },
                { label: '毛坯尺寸(mm)', name: 'RoughsSize', width: 140, align: 'left', sortable: false },
                { label: '宽度公差(mm)', name: 'KGC', width: 100, align: 'left', sortable: false },
                { label: '长度公差(mm)', name: 'CGC', width: 100, align: 'left', sortable: false },
                { label: '标准编号', name: 'StandardNumberAll', width: 130, align: 'left', sortable: false },
                { label: '特殊要求', name: 'MaterialDemandAll', width: 180, align: 'left', sortable: false },
                { label: '一级废料规格', name: 'FLGG1', width: 90, align: 'center', sortable: false },
                { label: '一级废料重量', name: 'FLZL1', width: 90, align: 'right', sortable: false },
                { label: '二级废料规格', name: 'FLGG2', width: 90, align: 'center', sortable: false },
                { label: '二级废料重量', name: 'FLZL2', width: 90, align: 'right', sortable: false },
                { label: '三级废料规格', name: 'FLGG3', width: 90, align: 'center', sortable: false },
                { label: '三级废料重量', name: 'FLZL3', width: 90, align: 'right', sortable: false },
                { label: '余料规格1(mm)', name: 'YLGG1', width: 180, align: 'left', sortable: false },
                { label: '余料数量1', name: 'YLSL1', width: 80, align: 'center', sortable: false },
                { label: '余料规格2(mm)', name: 'YLGG2', width: 180, align: 'left', sortable: false },
                { label: '余料数量2', name: 'YLSL2', width: 80, align: 'center', sortable: false },
                { label: '余料规格3(mm)', name: 'YLGG3', width: 180, align: 'left', sortable: false },
                { label: '余料数量3', name: 'YLSL3', width: 80, align: 'center', sortable: false },
                { label: '输入人员', name: 'InputUser', width: 70, align: 'left', sortable: false },
                { label: '输入日期', name: 'InputDate', width: 70, align: 'center', sortable: false },
                { label: '输入时间', name: 'InputTime', width: 70, align: 'center', sortable: false },
                { label: '审核人员', name: 'FAuditingBy', width: 80, align: 'left', sortable: false },
                { label: '审核日期', name: 'FAuditingDate', width: 70, align: 'center', sortable: false },
                { label: '审核时间', name: 'FAuditingTime', width: 70, align: 'center', sortable: false }
            ],
            pager: "#gridPager",
            sortname: 'MatNO asc',
            viewrecords: true,
            rownumWidth: 40,
            gridComplete: function () {
                
            },
            loadComplete: function () {
                hackHeight("#gridList");
                $gridList.jqGrid('setSelection', currRowId);
            },
            onSelectRow: function (rowid) {
                currRowId = rowid;
                var status = $("input[type='radio'].category:checked").val();
                if (status == 0 && currRowId > 0) {
                    $('#btn_check').removeClass('disabled');
                } else {
                    $('#btn_check').addClass('disabled');
                }
            },
            onPaging: function (page_btn) {
                currRowId = 1;
            }
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $gridList.jqGrid('setFrozenColumns');

        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { status: $("input[type='radio'].category:checked").val(), keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
        $('.category').on("click", function () {
            //$gridList.jqGrid("clearGridData")
            var status = $("input[type='radio'].category:checked").val();
            if (currStatus != status) {
                currStatus = status;
                currRowId = 1;
                $gridList.jqGrid('setGridParam', {
                    postData: { status: status, keyword: $("#txt_keyword").val() },
                }).trigger('reloadGrid');
            }
        })
    }
    function btn_add() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/BOM/Manufacture/ShearingBlankingInput"
        });
    }
    function btn_show() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/BOM/Manufacture/ShearingBlankingShow"
        });
    }
    function btn_check() {
        var $gridList = $("#gridList");
        var rowDatas = $gridList.jqGrid('getRowData', currRowId);
        //alert(rowDatas.MatListID);
        var keyValue = $("#gridList").jqGridRowValue().MatListID;
        $.modalConfirm("您确定要【审核】该条信息吗？", function (r) {
            if (r) {
                $.submitForm({
                    url: "/BOM/Product/SetJqxlItemChecked",
                    param: { keyValue: keyValue },
                    success: function () {
                        //$.currentWindow().$("#gridList").trigger("reloadGrid");
                        var status = $("input[type='radio'].category:checked").val();
                        var $gridList = $("#gridList");
                        $gridList.jqGrid('setGridParam', {
                            postData: { status: status, keyword: $("#txt_keyword").val() },
                        }).trigger('reloadGrid');
                    }
                })
            }
        });
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <form id="form1">
        <div style="padding: 12px 0 5px 0; padding-left: 15px; border-bottom: 1px solid #ccc;" class="line-table input-width-140">
            <div class="btn-group" style="margin-right:20px;">
                <input id="radio11" class="category" name="category" type="radio" value="0" checked="checked" /><label for="radio11" class="suffix">未审核</label><br />
                <input id="radio12" class="category" name="category" type="radio" value="1" /><label for="radio12" class="suffix">已审核</label> &nbsp;&nbsp;&nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                零件<br /><input id="txt_keyword" name="" placeholder="零件编号/零件名称" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span> 检索</a>
            </div>
            <div class="btn-group" style="float: right;">
                <a id="" class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span> 刷新</a>
                <a id="btn_check" class="btn btn-primary disabled" onclick="btn_check()"><span class="glyphicon glyphicon-flag"></span> 审核</a>                
                <a id="" class="btn btn-primary center-block" onclick="btn_show()"><span class="glyphicon glyphicon-plus"></span> 方案</a>
                <a id="" class="btn btn-primary center-block" onclick="btn_add()"><span class="glyphicon glyphicon-plus"></span> 新增</a>
                <a id="" class="btn btn-primary center-block disabled" onclick=""><span class="glyphicon glyphicon-edit"></span> 修改</a>
                <a id="" class="btn btn-primary center-block disabled" onclick=""><span class="glyphicon glyphicon-trash"></span> 删除</a>
                <a id="" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-download"></span> 导出</a>
            </div>
        </div>
    </form>
    <div style="">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</div>

